package com.fjrz.myapplication

import com.blankj.utilcode.util.LogUtils
import com.module.lemlin.http.HttpServiceRxHttpManager
import com.module.lemlin.http.ProgressListener
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import rxhttp.RxHttp
import rxhttp.await
import rxhttp.upload
import java.io.File

class BaseManager : HttpServiceRxHttpManager<BaseApi>(BaseApi::class.java) {

//    suspend fun upload(url: String, path: String, listener: ProgressListener? = null): Any {
//        return RxHttp.postForm(url)
//            .addHeader("token", "351b7027-0994-4771-b3fb-e4ece7a70168")
//            .addFile("file", File(path))
//            .upload(CoroutineScope(Dispatchers.Main)) {
//                LogUtils.e(it.progress)
//                listener?.onProgress(it)
//            }.await()
//    }

    suspend fun upload(url: String, path: String, listener: ProgressListener? = null): Any {
        return apiRxHttpService.upload(url,path,listener)
    }
}